package com.kaka.bus.engine.common.impl;

import com.kaka.bus.bean.BankBean;
import com.kaka.bus.bean.BpmList;
import com.kaka.bus.bean.HttpWrapper;
import com.kaka.bus.bean.Status;
import com.kaka.bus.engine.common.CommonService;
import com.kaka.bus.manager.Result;
import com.kaka.bus.manager.T;

import java.util.List;

import javax.inject.Inject;

/**
 * Created by OnionMac on 2018/7/30.
 */

public class LoanService extends CommonService{

    @Inject
    LoanService(){

    }

    /**
     * 节点列表
     * @param userId
     * @param token
     * @param result
     */
    public void getBpmList(String userId, String token,String productId, Result<HttpWrapper<List<BpmList>>> result) {
        addSubscribe(mDataManager.getApi()
                .getBpmList(userId,token,productId)
                .compose(T.D())
                .subscribeWith(result));
    }

    /**
     * 检查节点
     * @param userId
     * @param token
     * @param result
     */
    public void checkBpm(String userId,String token,Result<HttpWrapper<Status>> result) {
        addSubscribe(mDataManager.getApi()
                .checkNode(userId,token)
                .compose(T.D())
                .subscribeWith(result));
    }

    /**
     * 完成
     * @param userId
     * @param token
     * @param result
     */
    public void bpmFinish(String userId, String token, Result<HttpWrapper<String>> result) {
        addSubscribe(mDataManager.getApi()
                .NodeOk(userId,token,"")
                .compose(T.D())
                .subscribeWith(result));
    }

    /**
     * 上传通讯录
     *
     * @param userId
     * @param json
     * @param result
     */
    public void uploadContact(String userId, String json, Result<HttpWrapper<String>> result) {
        addSubscribe(mDataManager.getApi()
                .commitContact(userId,json)
                .compose(T.D())
                .subscribeWith(result));
    }

    /**
     * 拿到银行卡列表
     * @param result
     */
    public void getBankList(Result<HttpWrapper<List<BankBean>>> result){
        addSubscribe(mDataManager.getApi()
                .getBankList()
                .compose(T.D())
                .subscribeWith(result));
    }
}
